package com.test.deencredit.activity_deencredit.process_deencredit;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.PickVisualMediaRequest;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.test.deencredit.R;
import com.test.deencredit.activity_deencredit.ln_deencredit.LnAplyActivity_deencredit;
import com.test.deencredit.base_deencredit.BaseActivity_deencredit;
import com.test.deencredit.base_deencredit.BaseProcessWidgetManager_deencredit;
import com.test.deencredit.bean_deencredit.process_deencredit.ProcessInfo_deencredit;
import com.test.deencredit.bean_deencredit.process_deencredit.ProcessInfo_Data_deencredit;
import com.test.deencredit.bean_deencredit.process_deencredit.ProcessInfo_Step_deencredit;
import com.test.deencredit.bean_deencredit.userinfo_deencredit.AccountList_Fr_deencredit;
import com.test.deencredit.config_deencredit.CountryConfig_deencredit;
import com.test.deencredit.config_deencredit.PermissionConfig_deencredit;
import com.test.deencredit.config_deencredit.ProcessConfig_deencredit;
import com.test.deencredit.dialog_deencredit.BindAccountTipDialog_Fr_deencredit;
import com.test.deencredit.dialog_deencredit.CustomerServiceDialog_deencredit;
import com.test.deencredit.dialog_deencredit.SubmitAccountDialog_Fr_deencredit;
import com.test.deencredit.util_deencredit.UserInfoUtil_deencredit;
import com.test.deencredit.util_deencredit.http_deencredit.HttpUtil_deencredit;
import com.test.deencredit.util_deencredit.image_deencredit.ImageConvert_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.AddressPickViewManager_Tanzan_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.BindAccountViewManager_Fr_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.DateSelectViewManager_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.FaceViewManager_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.GenderSelectViewManager_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.InputViewManager_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.OcrViewManager_deencredit;
import com.test.deencredit.view_deencredit.process_widget_deencredit.SelectViewManager_deencredit;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;

public class ProcessActivity_deencredit extends BaseActivity_deencredit implements EasyPermissions.RationaleCallbacks,EasyPermissions.PermissionCallbacks{

    private TextView titleTv_deencredit, title2Tv_deencredit, textTv_deencredit;
    private LinearLayout groupLayout_deencredit;
    private View nextBtn_deencredit;

    private TextView processNumTv_deencredit;
    private LinearLayout processStepGroupLayout_deencredit;
    private ImageView processImgIv_deencredit;

    private ProcessInfo_Step_deencredit step_deencredit;

    private final ArrayList<BaseProcessWidgetManager_deencredit> processWidgetManagers_deencredit = new ArrayList<>();

    private BindAccountViewManager_Fr_deencredit bindAccountViewManager_deencredit;//法语区绑卡组件
    private OcrViewManager_deencredit ocrViewManager_deencredit;//Ocr组件
    private FaceViewManager_deencredit faceViewManager_deencredit;//Face组件

    private String path_deencredit;

    private Runnable nextBtnRunnable_deencredit;

    private ActivityResultLauncher<PickVisualMediaRequest> pickMedia_deencredit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_process_deencredit);

        page_deencredit = ProcessInfo_deencredit.getInstance_deencredit().getStepName_deencredit(0).toUpperCase();

        titleTv_deencredit = findViewById(R.id.ap_tv_title);
        title2Tv_deencredit = findViewById(R.id.ap_tv_title_2);
        textTv_deencredit = findViewById(R.id.ap_tv_text);

        processNumTv_deencredit = findViewById(R.id.ap_tv_processnum);
        processStepGroupLayout_deencredit = findViewById(R.id.ap_layout_process_step_group);
        processImgIv_deencredit = findViewById(R.id.ap_iv_process_img);

        findViewById(R.id.ap_ib_back).setOnClickListener(v -> onBackPressed());
        findViewById(R.id.ap_ib_customerservice).setOnClickListener(v -> new CustomerServiceDialog_deencredit(this).show());

        groupLayout_deencredit = findViewById(R.id.ap_layout_group);
        nextBtn_deencredit = findViewById(R.id.ap_btn_next);

        step_deencredit = ProcessInfo_deencredit.getInstance_deencredit().getStep_deencredit(0);
        path_deencredit = step_deencredit == null ? "": step_deencredit.getApiUrl_deencredit();

        initProcess_deencredit();
    }

    /**
     * 初始化流程
     */
    @SuppressLint("SetTextI18n")
    private void initProcess_deencredit(){
        if (step_deencredit == null) {
            onBackPressed();
            return;
        }

        initProcessStep_deencredit();

        titleTv_deencredit.setText(step_deencredit.getTitle_deencredit());
        title2Tv_deencredit.setText(step_deencredit.getTitle_deencredit());
        textTv_deencredit.setText(step_deencredit.getText_deencredit());

        String stepName = ProcessInfo_deencredit.getInstance_deencredit().getStepName_deencredit(0);
        if (!TextUtils.isEmpty(stepName)) page_deencredit = stepName.toUpperCase();

        //next
        nextBtn_deencredit.setOnClickListener(v -> {

            HttpUtil_deencredit.getInstance_deencredit().saveBuriedPoint_deencredit(page_deencredit,"SAVE_CLICK","");

            if (step_deencredit == null||TextUtils.isEmpty(path_deencredit)) {
                onBackPressed();
                return;
            }

            if (nextBtnRunnable_deencredit !=null) nextBtnRunnable_deencredit.run();

        });


        switch (stepName){
            case ProcessConfig_deencredit.Process_Step_Contact_deencredit:
                initContactProcess_deencredit();
                break;
            case ProcessConfig_deencredit.Process_Step_Ocr_deencredit:
                initOcrProcess_deencredit();
                break;
            case ProcessConfig_deencredit.Process_Step_Sefie_deencredit:
                initFaceProcess_deencredit();
                break;
            case ProcessConfig_deencredit.Process_Step_Account_deencredit:
                if (CountryConfig_deencredit.getInstance_deencredit().isFrench_deencredit()){
                    initBindAccountProcess_Fr_deencredit();
                    HttpUtil_deencredit.getInstance_deencredit().requestAccountList_Fr_deencredit(this,this::onFetchFrAccountListResponse_deencredit);
                    break;
                }
            default:
                initNormalProcess_deencredit();
        }

    }

    //初始化流程步骤显示
    private void initProcessStep_deencredit(){

        String currentStepName = ProcessInfo_deencredit.getInstance_deencredit().getStepName_deencredit(0);

        processNumTv_deencredit.setText(ProcessInfo_deencredit.getInstance_deencredit().getProcessNum_deencredit());
        processImgIv_deencredit.setBackgroundResource(ProcessConfig_deencredit.getProcessImgResId_deencredit(currentStepName));

        ArrayList<String> allSteps = ProcessInfo_deencredit.getInstance_deencredit().getAllSteps_deencredit();
        ArrayList<String> steps = ProcessInfo_deencredit.getInstance_deencredit().getSteps_deencredit();

        for (String stepName:allSteps){
            @SuppressLint("InflateParams") View view = LayoutInflater.from(this).inflate(R.layout.view_process_step_deencredit,null);
            View bgView = view.findViewById(R.id.vpsd_view_bg);
            view.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1));
            if (!steps.contains(stepName) || currentStepName.equalsIgnoreCase(stepName))
                bgView.setBackgroundResource(R.drawable.bg_process_step_true_deencredit);
            processStepGroupLayout_deencredit.addView(view);
        }

    }

    /**
     * 常规流程
     */
    private void initNormalProcess_deencredit(){

        for (int i = 0; i< step_deencredit.getDataListSize_deencredit(); i++){
            ProcessInfo_Data_deencredit data = step_deencredit.getProcessData_deencredit(i);
            if (data==null) continue;
            addInputView_deencredit(data,null);
        }

        //数据上报处理
        nextBtnRunnable_deencredit = () -> {

            for (BaseProcessWidgetManager_deencredit processWidgetManager: processWidgetManagers_deencredit){
                if (!processWidgetManager.checkInput_deencredit()){
                    Toast.makeText(this,getString(R.string.tips_input_empty_deencredit),Toast.LENGTH_SHORT).show();
                    return;
                }
            }


            TreeMap<String,String> dataMap = new TreeMap<>();

            for (BaseProcessWidgetManager_deencredit baseInfoInputViewManager: processWidgetManagers_deencredit){

                ProcessInfo_Data_deencredit data = baseInfoInputViewManager.getData_deencredit();
                if (data==null) continue;

                //地址联动模块
                if (data.getAction_deencredit().equalsIgnoreCase(ProcessConfig_deencredit.Data_Action_AddressPick_deencredit)){
                    //坦桑尼亚
                    if (CountryConfig_deencredit.getInstance_deencredit().isTanzan_deencredit()){
                        if (!(baseInfoInputViewManager instanceof AddressPickViewManager_Tanzan_deencredit)) continue;
                        AddressPickViewManager_Tanzan_deencredit addressPickTanzanManager = (AddressPickViewManager_Tanzan_deencredit) baseInfoInputViewManager;
                        dataMap.put(data.getParamName_deencredit(),addressPickTanzanManager.getState_deencredit());
                        dataMap.put(data.getParamNameCity_deencredit(),addressPickTanzanManager.getCity_deencredit());
                    }
                }
                //常规模块
                else dataMap.put(data.getParamName_deencredit(),baseInfoInputViewManager.getInput_deencredit());

            }

            HttpUtil_deencredit.getInstance_deencredit().submitProcessInfo_deencredit(this, path_deencredit,dataMap,this::onSubmitInfoResponse_deencredit);

        };

    }

    /**
     * 联系人流程
     */
    @SuppressLint("InflateParams")
    private void initContactProcess_deencredit(){

        for (int i = 0; i< step_deencredit.getExtDataListSize_deencredit(); i++){
            ProcessInfo_Data_deencredit data = step_deencredit.getExtProcessData_deencredit(i);
            if (data==null) continue;
            addInputView_deencredit(data,null);
        }

        //添加分割线
        if (step_deencredit.getExtDataListSize_deencredit()>0) groupLayout_deencredit.addView(LayoutInflater.from(this).inflate(R.layout.view_line_between_deencredit,null));

        int count = 0;

        while (count< step_deencredit.getItemCount_deencredit()){//联系人数量
            for (int i = 0; i< step_deencredit.getDataListSize_deencredit(); i++){
                ProcessInfo_Data_deencredit data = step_deencredit.getProcessData_deencredit(i);
                if (data==null) continue;
                addInputView_deencredit(data, step_deencredit.getRelationShips_deencredit(count));
            }
            //添加分割线
            if (++count < step_deencredit.getItemCount_deencredit()) groupLayout_deencredit.addView(LayoutInflater.from(this).inflate(R.layout.view_line_between_deencredit,null));
        }

        //数据上报处理
        nextBtnRunnable_deencredit = () -> {

            TreeMap<String,String> dataMap = new TreeMap<>();

            ArrayList<String> relashipList = new ArrayList<>();
            ArrayList<String> nameList = new ArrayList<>();
            ArrayList<String> phoneList = new ArrayList<>();

            for (BaseProcessWidgetManager_deencredit baseInfoInputViewManager: processWidgetManagers_deencredit){

                ProcessInfo_Data_deencredit data = baseInfoInputViewManager.getData_deencredit();
                if (data==null) continue;
                switch (data.getAction_deencredit()){

                    case ProcessConfig_deencredit.Data_Action_Contact_Relation_deencredit:
                        relashipList.add(((SelectViewManager_deencredit)baseInfoInputViewManager).getTextInput_deencredit());
                        break;

                    case ProcessConfig_deencredit.Data_Action_Contact_Name_deencredit:
                        nameList.add(baseInfoInputViewManager.getInput_deencredit());
                        break;

                    case ProcessConfig_deencredit.Data_Action_Contact_Phone_deencredit:
                        phoneList.add(baseInfoInputViewManager.getInput_deencredit());
                        break;

                    default: dataMap.put(data.getParamName_deencredit(),baseInfoInputViewManager.getInput_deencredit());
                }

            }

            //添加联系人信息
            if (!TextUtils.isEmpty(step_deencredit.getContactParamName_deencredit())){
                JSONArray jsonArray = new JSONArray();
                for (int i=0;i<relashipList.size();i++){
                    JSONObject jsonObject = new JSONObject();
                    try {
                        jsonObject.put("relation",relashipList.get(i));
                        if (i<nameList.size()) jsonObject.put("fullName",nameList.get(i));
                        if (i<phoneList.size()) jsonObject.put("mobile",phoneList.get(i));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    jsonArray.put(jsonObject);
                }
                dataMap.put(step_deencredit.getContactParamName_deencredit(),jsonArray.toString());
            }

            HttpUtil_deencredit.getInstance_deencredit().submitProcessInfo_deencredit(this, path_deencredit,dataMap,this::onSubmitInfoResponse_deencredit);

        };

    }

    /**
     * 法语区绑卡流程
     */
    private void initBindAccountProcess_Fr_deencredit(){

        @SuppressLint("InflateParams") View bindAccountView = LayoutInflater.from(this).inflate(R.layout.view_process_bindaccount_fr_deencredit,null);
        bindAccountViewManager_deencredit = new BindAccountViewManager_Fr_deencredit(bindAccountView,null, page_deencredit);
        groupLayout_deencredit.addView(bindAccountView);

        nextBtn_deencredit.setBackgroundResource(R.drawable.bg_purple_gray_rc24dp_deencredit);

        AccountList_Fr_deencredit.getInstance_deencredit().setParseRunnable_deencredit(() -> {
            if (AccountList_Fr_deencredit.getInstance_deencredit().getBankAccountList_deencredit().isEmpty())
                nextBtn_deencredit.setBackgroundResource(R.drawable.bg_purple_gray_rc24dp_deencredit);
            else
                nextBtn_deencredit.setBackgroundResource(R.drawable.bg_purple_rc_24dp_deencredit);
        });

        nextBtnRunnable_deencredit = () -> {

            if (bindAccountView == null) {
                onBackPressed();
                return;
            }

            if (AccountList_Fr_deencredit.getInstance_deencredit().getBankAccountList_deencredit().isEmpty()){//无绑卡提示
                Toast.makeText(this,"Veuillez ajouter au moins un compte de réception de prêt valide.",Toast.LENGTH_SHORT).show();
                return;
            }

            if (AccountList_Fr_deencredit.getInstance_deencredit().getBankAccountList_deencredit().size()<2){
                new BindAccountTipDialog_Fr_deencredit(this,() -> {
                    new SubmitAccountDialog_Fr_deencredit(this,() ->
                            //提交绑卡
                            HttpUtil_deencredit.getInstance_deencredit().submitProcessInfo_deencredit(this, path_deencredit,new TreeMap<String,String >(){{
                                put("bvn", UserInfoUtil_deencredit.getInstance_deencredit().getMobile_deencredit());
                            }},this::onSubmitInfoResponse_deencredit)
                            , page_deencredit).show();
                }).show();
                return;
            }

            new SubmitAccountDialog_Fr_deencredit(this,() ->
                //提交绑卡
                HttpUtil_deencredit.getInstance_deencredit().submitProcessInfo_deencredit(this, path_deencredit,new TreeMap<String,String >(){{
                    put("bvn", UserInfoUtil_deencredit.getInstance_deencredit().getMobile_deencredit());
                }},this::onSubmitInfoResponse_deencredit)
            , page_deencredit).show();

        };
    }

    /**
     * 人脸流程
     */
    private void initFaceProcess_deencredit(){

        @SuppressLint("InflateParams") View faceView = LayoutInflater.from(this).inflate(R.layout.view_process_face_deencredit,null);
        faceViewManager_deencredit = new FaceViewManager_deencredit(
                faceView,null, page_deencredit,
                this::onProcessInfoResponse_deencredit,
                () -> {if (faceViewManager_deencredit !=null) faceViewManager_deencredit.onPhotoUploadResponse_deencredit();}
        );
        groupLayout_deencredit.addView(faceView);

        nextBtnRunnable_deencredit = () -> {
            if (faceView==null || faceViewManager_deencredit ==null) {
                onBackPressed();
                return;
            }
            faceViewManager_deencredit.nextClick_deencredit(path_deencredit);
        };
    }

    /**
     * Ocr流程
     */
    private void initOcrProcess_deencredit(){

        @SuppressLint("InflateParams") View ocrView = LayoutInflater.from(this).inflate(R.layout.view_process_ocr_deencredit,null);
        ocrViewManager_deencredit = new OcrViewManager_deencredit(
                ocrView,null, page_deencredit,
                this::onProcessInfoResponse_deencredit,
                () -> {if (ocrViewManager_deencredit !=null) ocrViewManager_deencredit.onPhotoUploadResponse_deencredit();}
        );
        groupLayout_deencredit.addView(ocrView);

        pickMedia_deencredit = registerForActivityResult(new ActivityResultContracts.PickVisualMedia(), uri -> {
            if (uri!=null && ocrViewManager_deencredit !=null){
                ocrViewManager_deencredit.photoUri_deencredit = uri;
                ocrViewManager_deencredit.imgPath_deencredit = ImageConvert_deencredit.getBitmapFilePathFromURI_deencredit(this, ocrViewManager_deencredit.photoUri_deencredit);
                ocrViewManager_deencredit.onPhotoGet_deencredit();
            }
        });

        ocrViewManager_deencredit.setPickMedia_deencredit(pickMedia_deencredit);

        nextBtnRunnable_deencredit = () -> {
            if (ocrView == null || ocrViewManager_deencredit ==null) {
                onBackPressed();
                return;
            }
            ocrViewManager_deencredit.nextClick_deencredit(path_deencredit);
        };
    }

    /**
     * 添加信息输入控件
     * @param data 控件参数
     * @param relationships 联系人关系选项，可为空
     */
    @SuppressLint("InflateParams")
    private void addInputView_deencredit(ProcessInfo_Data_deencredit data, ArrayList<String> relationships){

        View inputView = null;

        switch (data.getAction_deencredit()){

            case ProcessConfig_deencredit.Data_Action_Select_deencredit:
                inputView = LayoutInflater.from(this).inflate(R.layout.view_process_select_deencredit,null);
                SelectViewManager_deencredit selectViewManager = new SelectViewManager_deencredit(inputView,data, page_deencredit);
                processWidgetManagers_deencredit.add(selectViewManager);
                break;

            case ProcessConfig_deencredit.Data_Action_DatePick_deencredit:
                inputView = LayoutInflater.from(this).inflate(R.layout.view_process_dateselect_deencredit,null);
                DateSelectViewManager_deencredit datePickWidgetsManager = new DateSelectViewManager_deencredit(inputView,data, page_deencredit);
                processWidgetManagers_deencredit.add(datePickWidgetsManager);
                break;

            case ProcessConfig_deencredit.Data_Action_Contact_Relation_deencredit://联系人-关系
                if (relationships!=null) data.setRelationships_deencredit(relationships);
                inputView = LayoutInflater.from(this).inflate(R.layout.view_process_select_deencredit,null);
                SelectViewManager_deencredit contactSelectViewManager = new SelectViewManager_deencredit(inputView,data, page_deencredit);
                processWidgetManagers_deencredit.add(contactSelectViewManager);
                break;

            case ProcessConfig_deencredit.Data_Action_GenderPick_deencredit:
                inputView = LayoutInflater.from(this).inflate(R.layout.view_process_genderselect_deencredit,null);
                GenderSelectViewManager_deencredit genderSelectViewManager = new GenderSelectViewManager_deencredit(inputView,data, page_deencredit);
                processWidgetManagers_deencredit.add(genderSelectViewManager);
                break;

            case ProcessConfig_deencredit.Data_Action_AddressPick_deencredit://地址联动模块
                //坦桑尼亚
                if (CountryConfig_deencredit.getInstance_deencredit().isTanzan_deencredit()){
                    inputView = LayoutInflater.from(this).inflate(R.layout.view_process_select_deencredit,null);
                    AddressPickViewManager_Tanzan_deencredit addressPickViewManagerTanzan = new AddressPickViewManager_Tanzan_deencredit(inputView,data, page_deencredit);
                    processWidgetManagers_deencredit.add(addressPickViewManagerTanzan);
                }
                break;

            case ProcessConfig_deencredit.Data_Action_Input_deencredit:
            case ProcessConfig_deencredit.Data_Action_Contact_Name_deencredit://联系人-名字
            case ProcessConfig_deencredit.Data_Action_Contact_Phone_deencredit://联系人-电话
            default:
                inputView = LayoutInflater.from(this).inflate(R.layout.view_process_input_deencredit,null);
                InputViewManager_deencredit inputWidgetsManager = new InputViewManager_deencredit(inputView,data, page_deencredit);
                processWidgetManagers_deencredit.add(inputWidgetsManager);
                break;
        }

        if (inputView!=null) groupLayout_deencredit.addView(inputView);
    }

    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {}

    @Override
    public void onRationaleDenied(int requestCode) {}

    @Override
    public void onRationaleAccepted(int requestCode) {
        if (requestCode == PermissionConfig_deencredit.PermissionCode_Camera_deencredit)
            EasyPermissions.requestPermissions(this,
                    getString(R.string.launch_permissions_camera_deencredit),
                    PermissionConfig_deencredit.PermissionCode_Camera_deencredit,
                    Manifest.permission.CAMERA);
    }

    @Override
    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
        if (requestCode == PermissionConfig_deencredit.PermissionCode_Camera_deencredit) {
            if (EasyPermissions.somePermissionPermanentlyDenied(this, perms))
                new AppSettingsDialog.Builder(this).build().show();
        }
    }


    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }


    @AfterPermissionGranted(PermissionConfig_deencredit.PermissionCode_Camera_deencredit)
    public void onCameraPermissionAgree_deencredit() {
        if (faceViewManager_deencredit != null) faceViewManager_deencredit.onCameraPermissionAgree_deencredit();
        else if (ocrViewManager_deencredit !=null) ocrViewManager_deencredit.onCameraPermissionAgree_deencredit();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (ocrViewManager_deencredit !=null && requestCode== OcrViewManager_deencredit.Flag_StartCamera_deencredit){
            ocrViewManager_deencredit.onPhotoGet_deencredit();
        }
    }

    //-------------------------------------------响应-----------------------------------------------------------

    //信息上报成功响应
    public void onSubmitInfoResponse_deencredit(){
        HttpUtil_deencredit.getInstance_deencredit().userProcess_deencredit(this,this::onProcessInfoResponse_deencredit);
    }

    public void onFetchFrAccountListResponse_deencredit(){
        if (bindAccountViewManager_deencredit !=null) bindAccountViewManager_deencredit.refreshAccountList_deencredit();
    }

    public void onProcessInfoResponse_deencredit(){
        //无流程：跳转到申请页
        if (ProcessInfo_deencredit.getInstance_deencredit().getSteps_deencredit().isEmpty())
            startActivity(new Intent(this, LnAplyActivity_deencredit.class));
            //有流程：跳转到流程页
        else startActivity(new Intent(this, ProcessActivity_deencredit.class));

        finish();
    }

}